package yifeng.thread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockExp {
	
	
	public static String data = "data";
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final Lock lock = new ReentrantLock();
		
		new Thread(new Runnable(){
			@Override
			public void run() {
				lock.lock();
				System.out.println("son thread is getting resources...");
				lock.unlock();
			}
		},"myThread").start();	
		
		
		lock.lock();
		System.out.println("main thread is getting resources...");
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("main thread is releasing resources...");
		lock.unlock();
		
	}

}
